package java9_2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Log4jDemo {
    public static final Logger Log = LoggerFactory.getLogger("java9_2.Log4jDemo");

    public static void main(String[] args) {
        Log.warn("小心，我在演示异常处理");
        if(Log.isDebugEnabled())
            Log.debug("计算方法开始了。。。");
        Log.info("构建了一个输入器！");
        Scanner sc = new Scanner(System.in);
        try {
            Log.debug("开始输入两个数字：");
            System.out.println("please input a :");
            int a = sc.nextInt();
            System.out.println("input b:");
            int b = sc.nextInt();
            int c = a / b;
            Log.info("商是：" + c);
            Log.info("得到了结果");
        } catch (InputMismatchException|ArithmeticException e) {
            Log.error("输入了错误的数字！" + e,e);

            //e.printStackTrace();
            /////System.exit(1);
        } finally {
            Log.info("运算结束了。。。");
        }


    }
}
